package view;

import controller.RegisterController;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
import javafx.stage.StageStyle;

import java.io.IOException;

public class PortraitView extends Window {

    private RegisterView registerView;

    public PortraitView(RegisterView registerView) throws IOException {
        root = FXMLLoader.load(getClass().getClassLoader().getResource("portrait.fxml"));
        Scene scene = new Scene(root, 600, 400);
        scene.setFill(Color.TRANSPARENT);
        setScene(scene);
        initStyle(StageStyle.TRANSPARENT);
        setResizable(false);
        setTitle("LightQ");

        this.registerView = registerView;
        choosePortrait();

        move();
    }

    private void choosePortrait() {
        for (int i=1; i<=12; i++) {
            int index = i;
            ((Button) findViewById("img" + i)).setOnAction(event -> {
                String s = "css/img/head/" + index + ".png";
                ((Button)registerView.findViewById("portrait")).setStyle("-fx-background-image: url(" + s + ");");
                RegisterController.imgPath = s;
                close();
            });
        }
    }

    @Override
    public void quit() {

    }

    @Override
    public void minimize() {

    }
}
